/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package unc.pds.facets;

import ru.perm.kefir.bbcode.BBProcessorFactory;
import ru.perm.kefir.bbcode.TextProcessor;
import unc.pds.model.DiaryRemote;
import unc.pds.model.UserRemote;

/**
 *
 * @author Михаил
 */
public class PostFacet implements Facet {
    private DiaryRemote diary;
    public PostFacet(DiaryRemote diary) {
        this.diary = diary;
    }
    public String draw() throws Exception {
        String result = "";
        TextProcessor processor = BBProcessorFactory.getInstance().create();
        result += "<p><h4>"+diary.getCaption()+" - "+((UserRemote)diary.getAuthor()).getNickname()+"</h4></p>\n";
        result += "<p><i>Создано "+DateFormatter.format(diary.getDate())+"</i></p>";
        result += "<p id=\"post\">"+processor.process(diary.getDiary())+"</p>\n";
        return result;
    }
    public boolean isSide() {
        return false;
    }
}
